;(function (window,$) {

        // 创建进度条对象
        function Progress(config) {
              return new Progress.prototype.init(this,config);
        }

        Progress.prototype = {
           constructor:Progress,
           init:function (pro_dom,config) {
                 config = config || {};
                 this.setStyle(pro_dom,config);
                 this.addEventListener(pro_dom,config);
           },
           setStyle:function (pro_dom,config) {
                 var styles = {
                     width:"5%",
                     height:config.height ||  "2px",
                     backgroundColor:config.backgroundColor || "#08f",
                     boxShadow:config.boxShadow || "",
                     position:"fixed",
                     top:"0",
                     transition:"width 0.5s ease-in-out"
                 };
                   for (let stylesKey in styles) {
                       pro_dom.css(stylesKey,styles[stylesKey]);
                   }
            },
            addEventListener:function (pro_dom,config) {
                    if(document.readyState === "loading") pro_dom.css("width","5%");
                    document.onreadystatechange = function () {
                        if (document.readyState === "interactive"){
                            pro_dom.css("width","30%");
                        }
                        if (document.readyState === "complete"){
                            pro_dom.css("width","100%");
                            setTimeout( function () {
                                pro_dom.css("display","none");
                                if(config.over){
                                    config.over();
                                }
                            },800)
                        }
                    }
            }
        };

        Progress.prototype.init.prototype = Progress.prototype;

        // 给Utils进行扩展
        $.fn.extends({progress:Progress})

})(window,Util);